/*    */ package com.zimbra.cs.datasource;
/*    */ 
/*    */ import com.zimbra.common.httpclient.HttpClientUtil;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.StringUtil;
/*    */ import com.zimbra.common.util.ZimbraHttpConnectionManager;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.DataSource;
/*    */ import com.zimbra.cs.account.DataSource.DataImport;
/*    */ import com.zimbra.cs.httpclient.HttpProxyUtil;
/*    */ import com.zimbra.cs.mailbox.Folder;
/*    */ import com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import java.util.List;
/*    */ import org.apache.commons.httpclient.HttpClient;
/*    */ import org.apache.commons.httpclient.methods.GetMethod;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RssImport
/*    */   implements DataSource.DataImport
/*    */ {
/*    */   private DataSource mDataSource;
/*    */   
/*    */   public RssImport(DataSource ds)
/*    */   {
/* 46 */     this.mDataSource = ds;
/*    */   }
/*    */   
/*    */   public void importData(List<Integer> folderIds, boolean fullSync) throws ServiceException {
/* 50 */     Mailbox mbox = DataSourceManager.getInstance().getMailbox(this.mDataSource);
/* 51 */     int folderId = this.mDataSource.getFolderId();
/*    */     try {
/* 53 */       mbox.getFolderById(null, folderId);
/* 54 */       mbox.synchronizeFolder(null, folderId);
/*    */     } catch (MailServiceException.NoSuchItemException e) {
/* 56 */       ZimbraLog.datasource.info("Folder %d was deleted.  Deleting data source %s.", new Object[] { Integer.valueOf(folderId), this.mDataSource.getName() });
/*    */       
/* 58 */       mbox.getAccount().deleteDataSource(this.mDataSource.getId());
/*    */     }
/*    */   }
/*    */   
/*    */   public void test() throws ServiceException
/*    */   {
/* 64 */     Mailbox mbox = DataSourceManager.getInstance().getMailbox(this.mDataSource);
/* 65 */     int folderId = this.mDataSource.getFolderId();
/*    */     
/* 67 */     Folder folder = mbox.getFolderById(null, folderId);
/* 68 */     String urlString = folder.getUrl();
/* 69 */     if (StringUtil.isNullOrEmpty(urlString)) {
/* 70 */       throw ServiceException.FAILURE("URL not specified for folder " + folder.getPath(), null);
/*    */     }
/* 72 */     GetMethod get = new GetMethod(urlString);
/*    */     try {
/* 74 */       HttpClient client = ZimbraHttpConnectionManager.getExternalHttpConnMgr().newHttpClient();
/* 75 */       HttpProxyUtil.configureProxy(client);
/* 76 */       HttpClientUtil.executeMethod(client, get);
/* 77 */       get.getResponseContentLength();
/*    */     } catch (Exception e) {
/* 79 */       throw ServiceException.FAILURE("Data source test failed.", e);
/*    */     } finally {
/* 81 */       get.releaseConnection();
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/datasource/RssImport.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */